package santeclair.connexion.util.processor.identification;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import santeclair.connexion.bean.trame.retour.identification.ResultatIdentification;
import santeclair.connexion.bean.trame.retour.identification.ResultatIdentificationSucces;
import santeclair.lunar.framework.aspect.processor.post.PostProcessor;
import santeclair.lunar.framework.aspect.processor.post.PostProcessorInterface;
import santeclair.referentiel.enumeration.OrganismeEnum;

@PostProcessor
@Component
public class MUTAIdentificationProcessor implements PostProcessorInterface<ResultatIdentification> {
    private static final Logger LOGGER = LoggerFactory.getLogger(MUTAIdentificationProcessor.class);

    public void postProcess(ResultatIdentification retour) {
        if (OrganismeEnum.MUTA.getCode().equals(retour.getAliasPartenaire())) {
            LOGGER.info("Lancement du post process d'identification pour MUTA");
            if (ResultatIdentificationSucces.class.isAssignableFrom(retour.getClass())) {
                ((ResultatIdentificationSucces) retour).setCodeGestion("MUTACITE");
            }
            LOGGER.debug("Fin du post process d'identification pour MUTA");
        }
    }
}
